package com.yyt.file_demo.utils;

import org.apache.commons.io.FileUtils;
import org.springframework.core.io.ClassPathResource;

import java.io.File;
import java.io.InputStream;

/**
 * @author yeyangtao created at 11:54 2020/9/7
 */
public class ResourceFileUtil {
    public void zipResources() {
        try (InputStream inputStream = new ClassPathResource("yyt/model.zip").getInputStream()) {
            System.out.println(inputStream.toString());
            FileUtils.copyToFile(inputStream, new File("/home/yyt/test/model.zip"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        // File file = ResourceUtils.getFile(ResourceUtils.CLASSPATH_URL_PREFIX + "model.zip");
        // 获取URL
        //URL url = getClass().getClassLoader().getResource("model.zip");

    }

    public static void main(String[] args){
        new ResourceFileUtil().zipResources();
    }
}
